<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>jQuery表单验证-试验三</title>
		<script src="js/jquery.min.js"></script>
		<script src="js/bootstrap.min.js"></script>
		<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
		<script type="text/javascript">
			function checkSid(){
				sidvalue = $("#studentid").val();
				regExp = /^[0-9]{9}$/;
				if (!regExp.test(sidvalue)) {
					$("#studentid").css("border","1px solid red");
					return false;
				} else {
					$("#studentid").css("border","");
					return true;
				}
			}
			
			function checkSname(){
				sname = $("#sname").val();
				regExp = /^[\u4e00-\u9fa5]{2,7}$/;
				if (!regExp.test(sname)) {
					$("#sname").css("border","1px solid red");
					return false;
				} else {
					$("#sname").css("border","");
					return true;
				}
			}
			function checkAll(){
				 flag1=checkSid();
				 flag2=checkSname()
				 return flag1&&flag2;
			}
		</script>
	</head>
	<body>
		学号<input onblur="checkSid()" class="form-control" type="text" id="studentid"><br>
		姓名<input onblur="checkSname()" class="form-control" type="text" id="sname"><br>
		<button onclick="checkAll()" class="btn btn-block btn-danger" type="button">注册</button>
	</body>
</html>
